import React, { Component } from 'react';
import Taro, { getCurrentInstance } from '@tarojs/taro';
import { View, Text, Button } from '@tarojs/components';
import './index.scss'
import { getAmacManagerDetail } from '@/services/api/fund';
import { formatDate, getNormarlReplace } from '@/utils/fomatter';

class FundManager extends Component {

    config = {
        navigationBarTitleText: ''
    }

    state = {
        data: {}
    }

    $instance = getCurrentInstance()

    componentWillMount() {
        this.requetData()
    }
    componentDidMount() { }
    componentWillReceiveProps(nextProps, nextContext) { }
    componentWillUnmount() { }

    requetData() {
        var params = this.$instance.router?.params
        console.log(params)
        if (params && params['fundManagerNo'].length > 0) {
            console.log(params)
            getAmacManagerDetail(params['fundManagerNo']).then((resp) => {
                if (resp.code === 200) {
                    this.setState({ data: resp.data })
                }
            });
        }
    }
    
    /**
     * 
     */
    gotoAsk(){
        Taro.navigateTo({url:"/consultQrCode/index"})
    }

    render() {
        const { data } = this.state
        const { safeArea } = Taro.getSystemInfoSync()

        return (
            <View className='page'>
                <View className='conetxt'>
                    <View className='header item-raduis'>
                        <Text className='header-title'>{data['managerName']}</Text>
                        <View className='header-context'>
                            <View className='header-context-item'>
                                <Text className='num'>{getNormarlReplace(data['assetScope'], '-')}</Text>
                                <Text className='header-context-item-desc'>管理规模</Text>
                            </View>
                            <View className='header-context-item'>
                                <Text>{getNormarlReplace(`${data['paidInCapital']}`, '-', '万')}</Text>
                                <Text className='header-context-item-desc'>实缴资本</Text>
                            </View>
                            <View className='header-context-item'>
                                <Text>{getNormarlReplace(data['lastUpdateTime'] ?? '', '-')}</Text>
                                <Text className='header-context-item-desc'>信息更新日期</Text>
                            </View>
                        </View>
                    </View>
                    <View className='org-info item-raduis'>
                        <Text className='title'>机构信息</Text>
                        <View className='l-r'>
                            <Text className='l-r-l'>登记编号</Text>
                            <Text className='l-r-r'>{getNormarlReplace(data['registerNo'], '-')}</Text>
                        </View>
                        <View className='l-r'>
                            <Text className='l-r-l'>成立日期</Text>
                            <Text className='l-r-r'>{getNormarlReplace(formatDate(data['establishDate'], 'yyyy-MM-DD'), '-')}</Text>
                        </View>
                        <View className='l-r'>
                            <Text className='l-r-l'>登记日期</Text>
                            <Text className='l-r-r'>{getNormarlReplace(formatDate(data['registerDate'], 'yyy-MM-DD'), '-')}</Text>
                        </View>
                        <View className='l-r'>
                            <Text className='l-r-l'>注册地点</Text>
                            <Text className='l-r-r'>{getNormarlReplace(data['registercity'], '-')}</Text>
                        </View>
                        <View className='l-r'>
                            <Text className='l-r-l'>办公地点</Text>
                            <Text className='l-r-r'>{getNormarlReplace(data['officeCity'], '-')}</Text>
                        </View>
                        <View className='l-r'>
                            <Text className='l-r-l'>企业性质</Text>
                            <Text className='l-r-r'>{getNormarlReplace(data['organizationCode'], '-')}</Text>
                        </View>
                        <View className='l-r'>
                            <Text className='l-r-l'>机构类型</Text>
                            <Text className='l-r-r'>{getNormarlReplace(data['primaryInvestType'], '-')}</Text>
                        </View>
                        <View className='l-r'>
                            <Text className='l-r-l'>业务类型</Text>
                            <Text className='l-r-r'>{getNormarlReplace(data['businessType'], '-')}</Text>
                        </View>
                        <View className='l-r'>
                            <Text className='l-r-l'>注册资本</Text>
                            <Text className='l-r-r'>{getNormarlReplace(`${data['registeredCapital']}`, '-', '万元')}</Text>
                        </View>
                        <View className='l-r'>
                            <Text className='l-r-l'>实缴资本</Text>
                            <Text className='l-r-r'>{getNormarlReplace(`${data['paidInCapital']}`, '-', '万元')}</Text>
                        </View>
                        <View className='l-r'>
                            <Text className='l-r-l'>组织机构代码</Text>
                            <Text className='l-r-r'>{getNormarlReplace(data['organizationCode'], '-')}</Text>
                        </View>
                    </View>
                    {
                        (data['memberType'] !== undefined && data['memberType'].length > 0 && data['memberType'] !== "非会员机构") ?
                            <View className='member-info item-raduis'>
                                <Text className='title'>会员信息</Text>
                                <View className='l-r'>
                                    <Text className='l-r-l'>是否会员</Text>
                                    <Text className='l-r-r'>是</Text>
                                </View>
                                <View className='l-r'>
                                    <Text className='l-r-l'>会员类型</Text>
                                    <Text className='l-r-r'>{getNormarlReplace(data['memberType'], '-')}</Text>
                                </View>
                                <View className='l-r'>
                                    <Text className='l-r-l'>会员代表</Text>
                                    <Text className='l-r-r'>{getNormarlReplace(data['memberRepresent'], '-')}</Text>
                                </View>
                                <View className='l-r'>
                                    <Text className='l-r-l'>入会时间</Text>
                                    <Text className='l-r-r'>{getNormarlReplace(data['joiningTime'], '-')}</Text>
                                </View>
                            </View>
                            :
                            <View className='member-info item-raduis'>
                                <Text className='title'>会员信息</Text>
                                <View className='l-r'>
                                    <Text className='l-r-l'>是否会员</Text>
                                    <Text className='l-r-r'>否</Text>
                                </View>
                            </View>
                    }
                    {
                        (data['legalOpinionStatus'] !== undefined && data['legalOpinionStatus'].length > 0) ? <View className='law-info item-raduis'>
                            <Text className='title'>法律意见书</Text>
                            <View className='l-r'>
                                <Text className='l-r-l'>状态</Text>
                                <Text className='l-r-r'>{getNormarlReplace(data['legalOpinionStatus'], '-')}</Text>
                            </View>
                            <View className='l-r'>
                                <Text className='l-r-l'>律所</Text>
                                <Text className='l-r-r'>{getNormarlReplace(data['lawFirmName'], '-')}</Text>
                            </View>
                            <View className='l-r'>
                                <Text className='l-r-l'>律师</Text>
                                <Text className='l-r-r'>{getNormarlReplace(data['lawyerName'], '-')}</Text>
                            </View>
                        </View> : null
                    }
                </View>
                <View className='bottom' style={{ paddingBottom: safeArea.top + 16 }}>
                    <Button className='ask-kf' onClick={this.gotoAsk.bind(this)}>立即咨询</Button>
                </View>
            </View>

        );
    }
}

export default FundManager;